home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 3 / Cream of the Crop 3.iso / science / mcalc13.zip / MCALCARE.C < prev    next >
C/C++ Source or Header  |  1994-02-15  |  19KB  |  780 lines

  1. /*
  2. Auto:        smake MCalc
  3. */
  4.  
  5. /* $Revision Header built automatically *************** (do not edit) ************
  6. **
  7. ** ⌐ Copyright by GuntherSoft
  8. **
  9. ** File             : SnakeSYS:CPrgs/MUICalc/MCalcARexx.c
  10. ** Created on       : Sunday, 05.12.93 14:37:01
  11. ** Created by       : Kai Iske
  12. ** Current revision : V1.0
  13. **
  14. **
  15. ** Purpose
  16. ** -------
  17. **   - ARexx support for MUIProCalc
  18. **
  19. ** Revision V1.0
  20. ** --------------
  21. ** created on Sunday, 05.12.93 14:37:01  by  Kai Iske.   LogMessage :
  22. **     --- Initial release ---
  23. **
  24. *********************************************************************************/
  25.  
  26.  
  27.  
  28.  
  29.  
  30. /**********************************************************************/
  31. /*                      Routines for that module                      */
  32. /**********************************************************************/
  33. static APTR __saveds __asm DoRXCalc(register __a0 struct Hook *MyHook, register __a2 APTR *MyObject, register __a1 ULONG *Parms);
  34. static APTR __saveds __asm DoRXCalcTeX(register __a0 struct Hook *MyHook, register __a2 APTR *MyObject, register __a1 ULONG *Parms);
  35. static APTR __saveds __asm GetOutput(register __a0 struct Hook *MyHook, register __a2 APTR *MyObject, register __a1 ULONG *Parms);
  36. static APTR __saveds __asm GetTeXOutput(register __a0 struct Hook *MyHook, register __a2 APTR *MyObject, register __a1 ULONG *Parms);
  37. static APTR __saveds __asm GetInput(register __a0 struct Hook *MyHook, register __a2 APTR *MyObject, register __a1 ULONG *Parms);
  38. static APTR __saveds __asm GetTeXInput(register __a0 struct Hook *MyHook, register __a2 APTR *MyObject, register __a1 ULONG *Parms);
  39. static APTR __saveds __asm DoFormatTeX(register __a0 struct Hook *MyHook, register __a2 APTR *MyObject, register __a1 ULONG *Parms);
  40. static APTR __saveds __asm SetMode(register __a0 struct Hook *MyHook, register __a2 APTR *MyObject, register __a1 ULONG *Parms);
  41. static APTR ReturnEntry(UWORD Mode, UWORD OutMode, LONG Pos);
  42. static void FormatTeX(char *Source, char *Dest);
  43.  
  44.  
  45. /**********************************************************************/
  46. /*           external references to main programs variables           */
  47. /**********************************************************************/
  48. extern APTR    AppObject;
  49. extern APTR    InputString;
  50. extern APTR    OutputBox;
  51. extern UWORD    IntType;
  52. extern UWORD    IntBase;
  53. extern UWORD    IntSign;
  54. extern UWORD    IntAngle;
  55.  
  56.  
  57.  
  58.  
  59. /**********************************************************************/
  60. /*                               Hooks                                */
  61. /**********************************************************************/
  62. static struct Hook CalcHook =
  63. {
  64.     {NULL},
  65.     (APTR)DoRXCalc,
  66.     NULL,
  67.     NULL
  68. };
  69.  
  70. static struct Hook CalcTeXHook =
  71. {
  72.     {NULL},
  73.     (APTR)DoRXCalcTeX,
  74.     NULL,
  75.     NULL
  76. };
  77.  
  78. static struct Hook GetOutputHook =
  79. {
  80.     {NULL},
  81.     (APTR)GetOutput,
  82.     NULL,
  83.     NULL
  84. };
  85.  
  86. static struct Hook GetTeXOutputHook =
  87. {
  88.     {NULL},
  89.     (APTR)GetTeXOutput,
  90.     NULL,
  91.     NULL
  92. };
  93.  
  94. static struct Hook GetInputHook =
  95. {
  96.     {NULL},
  97.     (APTR)GetInput,
  98.     NULL,
  99.     NULL
  100. };
  101.  
  102. static struct Hook GetTeXInputHook =
  103. {
  104.     {NULL},
  105.     (APTR)GetTeXInput,
  106.     NULL,
  107.     NULL
  108. };
  109.  
  110. static struct Hook FormatTeXHook =
  111. {
  112.     {NULL},
  113.     (APTR)DoFormatTeX,
  114.     NULL,
  115.     NULL
  116. };
  117.  
  118. static struct Hook SetModeHook =
  119. {
  120.     {NULL},
  121.     (APTR)SetMode,
  122.     NULL,
  123.     NULL
  124. };
  125.  
  126.  
  127.  
  128.  
  129. /**********************************************************************/
  130. /*                       This is for our modes                        */
  131. /**********************************************************************/
  132. UWORD    RXIntType;
  133. UWORD    RXIntBase;
  134. UWORD    RXIntSign;
  135. UWORD    RXIntAngle;
  136.  
  137.  
  138.  
  139.  
  140. /**********************************************************************/
  141. /*               Array of ARexx commands for MUIProCalc               */
  142. /**********************************************************************/
  143. struct    MUI_Command    RXCommands[] =
  144. {
  145.         // Calculate an expression (normal output)
  146.  
  147.     {
  148.         "CALC",
  149.         "EXPRESSION/A/M",
  150.         1,
  151.         &CalcHook
  152.     },
  153.  
  154.         // Calculate an expression (TeX output)
  155.  
  156.     {
  157.         "CALCTEX",
  158.         "EXPRESSION/A/M",
  159.         1,
  160.         &CalcTeXHook
  161.     },
  162.  
  163.         // Select output from history (normal output; as is)
  164.  
  165.     {
  166.         "GETOUTPUT",
  167.         "ENTRYNUM/N",
  168.         1,
  169.         &GetOutputHook
  170.     },
  171.  
  172.         // Select output from history (TeX output)
  173.  
  174.     {
  175.         "GETTEXOUTPUT",
  176.         "ENTRYNUM/N",
  177.         1,
  178.         &GetTeXOutputHook
  179.     },
  180.  
  181.         // Select input from history (normal output; as is)
  182.  
  183.     {
  184.         "GETINPUT",
  185.         "ENTRYNUM/N",
  186.         1,
  187.         &GetInputHook
  188.     },
  189.  
  190.         // Select input from history (TeX output)
  191.  
  192.     {
  193.         "GETTEXINPUT",
  194.         "ENTRYNUM/N",
  195.         1,
  196.         &GetTeXInputHook
  197.     },
  198.  
  199.  
  200.         // Format an expression to TeX format
  201.  
  202.     {
  203.         "FORMATTEX",
  204.         "EXPRESSION/A/M",
  205.         1,
  206.         &FormatTeXHook
  207.     },
  208.  
  209.  
  210.         // Set output mode
  211.  
  212.     {
  213.         "SETMODE",
  214.         "BASE/K,SIZE/K,SIGN/K,ANGLE/K",
  215.         4,
  216.         &SetModeHook
  217.     },
  218.  
  219.  
  220.  
  221.         // Delimiter
  222.  
  223.     {
  224.         NULL, NULL, NULL, NULL
  225.     }
  226. };
  227.  
  228.  
  229.  
  230.  
  231.  
  232. /**********************************************************************/
  233. /*        Let MUIProCalc (normal output) calculate through ARexx      */
  234. /*        ------------------------------------------------------      */
  235. /* Parameters must be :                                               */
  236. /* Expr  = Expression to calculate                                    */
  237. /**********************************************************************/
  238. static APTR __saveds __asm DoRXCalc(register __a0 struct Hook *MyHook, register __a2 APTR *MyObject, register __a1 ULONG *Parms)
  239. {
  240.     UWORD    BackIntType, BackIntBase, BackIntSign, BackIntAngle;
  241.     char    NewBuff[258], **Exprs;
  242.     BOOL    GoOn = TRUE;
  243.  
  244.         // Build expression from partial input
  245.  
  246.     strcpy(NewBuff, "");
  247.     Exprs = (char **)Parms[0];
  248.     while(*Exprs && GoOn)
  249.     {
  250.         if((strlen(*Exprs) + strlen(NewBuff)) < 256)
  251.             strcat(NewBuff, *Exprs);
  252.         else
  253.             GoOn = FALSE;
  254.  
  255.         Exprs++;
  256.     }
  257.  
  258.         // Set input string to current expression
  259.  
  260.     set(InputString, MUIA_String_Contents, NewBuff);
  261.  
  262.         // Calculate expression (with ARexx settings)
  263.  
  264.     BackIntType    = IntType;
  265.     BackIntBase    = IntBase;
  266.     BackIntSign    = IntSign;
  267.     BackIntAngle    = IntAngle;
  268.  
  269.     IntType        = RXIntType;
  270.     IntBase        = RXIntBase;
  271.     IntSign        = RXIntSign;
  272.     IntAngle    = RXIntAngle;
  273.  
  274.     GoOn = FormatOutput(FALSE);
  275.  
  276.     IntType        = BackIntType;
  277.     IntBase        = BackIntBase;
  278.     IntSign        = BackIntSign;
  279.     IntAngle    = BackIntAngle;
  280.  
  281.     if(GoOn)
  282.     {
  283.  
  284.             // Return output
  285.  
  286.         return(ReturnEntry(GET_OUTPUT, NORMAL_OUTPUT, GET_ACTIVE));
  287.     }
  288.     else
  289.         return((APTR)set(AppObject, MUIA_Application_RexxString,  " "));
  290. }
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297. /**********************************************************************/
  298. /*         Let MUIProCalc (TeX output) calculate through ARexx        */
  299. /*         ---------------------------------------------------        */
  300. /* Parameters must be :                                               */
  301. /* Expr  = Expression to calculate                                    */
  302. /**********************************************************************/
  303. static APTR __saveds __asm DoRXCalcTeX(register __a0 struct Hook *MyHook, register __a2 APTR *MyObject, register __a1 ULONG *Parms)
  304. {
  305.     UWORD    BackIntType, BackIntBase, BackIntSign, BackIntAngle;
  306.     char    NewBuff[258], **Exprs;
  307.     BOOL    GoOn = TRUE;
  308.  
  309.         // Build expression from partial input
  310.  
  311.     strcpy(NewBuff, "");
  312.     Exprs = (char **)Parms[0];
  313.     while(*Exprs && GoOn)
  314.     {
  315.         if((strlen(*Exprs) + strlen(NewBuff)) < 256)
  316.             strcat(NewBuff, *Exprs);
  317.         else
  318.             GoOn = FALSE;
  319.  
  320.         Exprs++;
  321.     }
  322.  
  323.         // Set input string to current expression
  324.  
  325.     set(InputString, MUIA_String_Contents, NewBuff);
  326.  
  327.         // Calculate expression (with ARexx settings)
  328.  
  329.     BackIntType    = IntType;
  330.     BackIntBase    = IntBase;
  331.     BackIntSign    = IntSign;
  332.     BackIntAngle    = IntAngle;
  333.  
  334.     IntType        = RXIntType;
  335.     IntBase        = RXIntBase;
  336.     IntSign        = RXIntSign;
  337.     IntAngle    = RXIntAngle;
  338.  
  339.     GoOn = FormatOutput(FALSE);
  340.  
  341.     IntType        = BackIntType;
  342.     IntBase        = BackIntBase;
  343.     IntSign        = BackIntSign;
  344.     IntAngle    = BackIntAngle;
  345.  
  346.     if(GoOn)
  347.     {
  348.  
  349.             // Return output
  350.  
  351.         return(ReturnEntry(GET_OUTPUT, TEX_OUTPUT, GET_ACTIVE));
  352.     }
  353.     else
  354.         return((APTR)set(AppObject, MUIA_Application_RexxString,  " "));
  355. }
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362. /**********************************************************************/
  363. /*               GetOutput (normal output) from History               */
  364. /*               --------------------------------------               */
  365. /* Parameters may be :                                                */
  366. /* n    = Nth entry                                                   */
  367. /* -1   = Active entry                                                */
  368. /* -2   = TopMost entry                                               */
  369. /* -3   = BottomMost entry                                            */
  370. /* default :                                                          */
  371. /*        get active entry                                            */
  372. /**********************************************************************/
  373. static APTR __saveds __asm GetOutput(register __a0 struct Hook *MyHook, register __a2 APTR *MyObject, register __a1 ULONG *Parms)
  374. {
  375.     LONG    *ValuePtr = (LONG *)Parms[0],
  376.         Value;
  377.  
  378.     if(ValuePtr)
  379.         Value    = *ValuePtr;
  380.     else
  381.         Value    = -1;
  382.  
  383.     return(ReturnEntry(GET_OUTPUT, NORMAL_OUTPUT, Value));
  384. }
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391. /**********************************************************************/
  392. /*                GetOutput (TeX output) from History                 */
  393. /*                -----------------------------------                 */
  394. /* Parameters may be :                                                */
  395. /* n    = Nth entry                                                   */
  396. /* -1   = Active entry                                                */
  397. /* -2   = TopMost entry                                               */
  398. /* -3   = BottomMost entry                                            */
  399. /* default :                                                          */
  400. /*        get active entry                                            */
  401. /**********************************************************************/
  402. static APTR __saveds __asm GetTeXOutput(register __a0 struct Hook *MyHook, register __a2 APTR *MyObject, register __a1 ULONG *Parms)
  403. {
  404.     LONG    *ValuePtr = (LONG *)Parms[0],
  405.         Value;
  406.  
  407.     if(ValuePtr)
  408.         Value    = *ValuePtr;
  409.     else
  410.         Value    = -1;
  411.  
  412.     return(ReturnEntry(GET_OUTPUT, TEX_OUTPUT, Value));
  413. }
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421. /**********************************************************************/
  422. /*                GetInput (normal input) from History                */
  423. /*                ------------------------------------                */
  424. /* Parameters may be :                                                */
  425. /* n    = Nth entry                                                   */
  426. /* -1   = Active entry                                                */
  427. /* -2   = TopMost entry                                               */
  428. /* -3   = BottomMost entry                                            */
  429. /* default :                                                          */
  430. /*        get active entry                                            */
  431. /**********************************************************************/
  432. static APTR __saveds __asm GetInput(register __a0 struct Hook *MyHook, register __a2 APTR *MyObject, register __a1 ULONG *Parms)
  433. {
  434.     LONG    *ValuePtr = (LONG *)Parms[0],
  435.         Value;
  436.  
  437.     if(ValuePtr)
  438.         Value    = *ValuePtr;
  439.     else
  440.         Value    = -1;
  441.  
  442.     return(ReturnEntry(GET_INPUT, NORMAL_OUTPUT, Value));
  443. }
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451. /**********************************************************************/
  452. /*                 GetInput (TeX input) from History                  */
  453. /*                 ---------------------------------                  */
  454. /* Parameters may be :                                                */
  455. /* n    = Nth entry                                                   */
  456. /* -1   = Active entry                                                */
  457. /* -2   = TopMost entry                                               */
  458. /* -3   = BottomMost entry                                            */
  459. /* default :                                                          */
  460. /*        get active entry                                            */
  461. /**********************************************************************/
  462. static APTR __saveds __asm GetTeXInput(register __a0 struct Hook *MyHook, register __a2 APTR *MyObject, register __a1 ULONG *Parms)
  463. {
  464.     LONG    *ValuePtr = (LONG *)Parms[0],
  465.         Value;
  466.  
  467.     if(ValuePtr)
  468.         Value    = *ValuePtr;
  469.     else
  470.         Value    = -1;
  471.  
  472.     return(ReturnEntry(GET_INPUT, TEX_OUTPUT, Value));
  473. }
  474.  
  475.  
  476.  
  477.  
  478.  
  479.  
  480.  
  481.  
  482. /**********************************************************************/
  483. /*                 Format an expression to TeX format                 */
  484. /*                 ----------------------------------                 */
  485. /* Parameters must be                                                 */
  486. /* Expr  = Expression to convert                                      */
  487. /**********************************************************************/
  488. static APTR __saveds __asm DoFormatTeX(register __a0 struct Hook *MyHook, register __a2 APTR *MyObject, register __a1 ULONG *Parms)
  489. {
  490.     char    NewBuff[512], **Exprs;
  491.     char    OutBuff[840];
  492.     BOOL    GoOn = TRUE;
  493.  
  494.         // Build expression from partial input
  495.  
  496.     strcpy(NewBuff, "");
  497.     Exprs = (char **)Parms[0];
  498.     while(*Exprs && GoOn)
  499.     {
  500.         if((strlen(*Exprs) + strlen(NewBuff)) < 256)
  501.             strcat(NewBuff, *Exprs);
  502.         else
  503.             GoOn = FALSE;
  504.  
  505.         Exprs++;
  506.     }
  507.  
  508.         // Format output
  509.  
  510.     FormatTeX(NewBuff, OutBuff);
  511.  
  512.         // Return RexxString
  513.  
  514.     return((APTR)set(AppObject, MUIA_Application_RexxString,  OutBuff));
  515. }
  516.  
  517.  
  518.  
  519.  
  520.  
  521. /**********************************************************************/
  522. /*               Set outputmodes for ARexx Calculation                */
  523. /*               -------------------------------------                */
  524. /* Parameters may be :                                                */
  525. /* BASE  = Set the output base                                        */
  526. /* SIZE  = Set output size                                            */
  527. /* SIGN  = Set signed/unsigned output                                 */
  528. /* ANGLE = Set default angle                                          */
  529. /**********************************************************************/
  530. static APTR __saveds __asm SetMode(register __a0 struct Hook *MyHook, register __a2 APTR *MyObject, register __a1 ULONG *Parms)
  531. {
  532.     char    *ThisVal;
  533.  
  534.         // Check for BASE keyword
  535.  
  536.     if((ThisVal = (char *)Parms[0]))
  537.     {
  538.         if(MatchToolValue(ThisVal, "DEC"))
  539.             RXIntType    = ID_DECIMAL;
  540.         else if(MatchToolValue(ThisVal, "HEX"))
  541.             RXIntType    = ID_HEXDECIMAL;
  542.         else if(MatchToolValue(ThisVal, "OCT"))
  543.             RXIntType    = ID_OCTAL;
  544.         else if(MatchToolValue(ThisVal, "BIN"))
  545.             RXIntType    = ID_BINARY;
  546.     }
  547.  
  548.         // Check for SIZE keyword
  549.  
  550.     if((ThisVal = (char *)Parms[1]))
  551.     {
  552.         if(MatchToolValue(ThisVal, "8"))
  553.             RXIntBase    = ID_8BIT;
  554.         else if(MatchToolValue(ThisVal, "16"))
  555.             RXIntBase    = ID_16BIT;
  556.         else if(MatchToolValue(ThisVal, "32"))
  557.             RXIntBase    = ID_32BIT;
  558.     }
  559.  
  560.         // Check for SIGN keyword
  561.  
  562.     if((ThisVal = (char *)Parms[2]))
  563.     {
  564.         if(MatchToolValue(ThisVal, "SIGNED"))
  565.             RXIntSign    = ID_SIGNED;
  566.         else if(MatchToolValue(ThisVal, "UNSIGNED"))
  567.             RXIntSign    = ID_UNSIGNED;
  568.     }
  569.  
  570.  
  571.         // Check for ANGLE keyword
  572.  
  573.     if((ThisVal = (char *)Parms[3]))
  574.     {
  575.         if(MatchToolValue(ThisVal, "RAD"))
  576.             RXIntAngle    = ID_RAD;
  577.         else if(MatchToolValue(ThisVal, "DEG"))
  578.             RXIntAngle    = ID_DEG;
  579.     }
  580.  
  581.     return(NULL);
  582. }
  583.  
  584.  
  585.  
  586. /**********************************************************************/
  587. /*                       Return a normal entry                        */
  588. /**********************************************************************/
  589. static APTR ReturnEntry(UWORD Mode, UWORD OutMode, LONG Pos)
  590. {
  591.     struct    ListStruct    *LSV    = NULL;
  592.     char    *Source;
  593.     char    OutBuffer[300];
  594.  
  595.         // Get appropriate entry
  596.  
  597.     if(Pos == GET_ACTIVE)
  598.         DoMethod(OutputBox, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &LSV);
  599.     else if(Pos == GET_TOPMOST)
  600.         DoMethod(OutputBox, MUIM_List_GetEntry, 0, &LSV);
  601.     else if(Pos == GET_BOTTOMMOST)
  602.     {
  603.         struct    ListStruct    *Dummy;
  604.         ULONG    i;
  605.  
  606.             // Move to end of list
  607.  
  608.         for(i = 0;; i++)
  609.         {
  610.             DoMethod(OutputBox, MUIM_List_GetEntry, i, &Dummy);
  611.  
  612.             if(Dummy)
  613.                 LSV = Dummy;
  614.             else
  615.                 break;
  616.         }
  617.     }
  618.     else
  619.     {
  620.         ULONG    NumEntries;
  621.  
  622.             // First check, whether entry argument is appropriate
  623.  
  624.         get(OutputBox, MUIA_List_Entries, &NumEntries);
  625.  
  626.         if(Pos < GET_BOTTOMMOST || Pos >= NumEntries)
  627.             Pos    = MUIV_List_GetEntry_Active;
  628.  
  629.         DoMethod(OutputBox, MUIM_List_GetEntry, Pos, &LSV);
  630.     }
  631.  
  632.     if(LSV)
  633.     {
  634.             // Get correct source of input
  635.  
  636.         Source    = ((Mode == GET_OUTPUT) ? LSV->Output : LSV->Input);
  637.  
  638.         if(OutMode == NORMAL_OUTPUT)
  639.             strncpy(OutBuffer, Source, 299);
  640.         else
  641.             FormatTeX(Source, OutBuffer);
  642.  
  643.             // Not to return Error message ?!?
  644.  
  645.         if(strncmp(Source, "\0338", 2))
  646.         {
  647.                 // Return RexxString
  648.  
  649.             return((APTR)set(AppObject, MUIA_Application_RexxString,  OutBuffer));
  650.         }
  651.         else
  652.             return((APTR)set(AppObject, MUIA_Application_RexxString,  " "));
  653.     }
  654.     else
  655.         return((APTR)set(AppObject, MUIA_Application_RexxString,  " "));
  656. }
  657.  
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.  
  665. /**********************************************************************/
  666. /*            Format a given entry according to TeX rules             */
  667. /**********************************************************************/
  668. static void FormatTeX(char *Source, char *Dest)
  669. {
  670.     char    *CopyDest    = Dest;
  671.     BOOL    HexMode        = FALSE;
  672.     BOOL    PowMode        = FALSE;
  673.     UWORD    BraceMode    = 0;
  674.  
  675.     while(*Source)
  676.     {
  677.         if(*Source == '$')
  678.         {
  679.             *Dest++    = '\\';
  680.             *Dest++    = '$';
  681.             Source++;
  682.  
  683.             HexMode    = TRUE;
  684.         }
  685.  
  686.         if(*Source == '0' && (*(Source + 1) == 'x' || *(Source + 1) == 'X'))
  687.         {
  688.             *Dest++    = '\\';
  689.             *Dest++    = '$';
  690.             Source++;
  691.             Source++;
  692.  
  693.             HexMode    = TRUE;
  694.         }
  695.  
  696.         else if(*Source == '*')
  697.         {
  698.             *Dest    = '\0';
  699.             strcat(CopyDest, "\\cdot ");
  700.             Dest    = CopyDest + strlen(CopyDest);
  701.             Source++;
  702.  
  703.             HexMode    = FALSE;
  704.         }
  705.  
  706.         else if(*Source == '\\')
  707.         {
  708.             *Dest++    = '\\';
  709.  
  710.             HexMode    = FALSE;
  711.         }
  712.  
  713.         else if(*Source == '&')
  714.         {
  715.             *Dest++    = '\\';
  716.             *Dest++    = *Source++;
  717.  
  718.             HexMode    = FALSE;
  719.         }
  720.  
  721.         else if(*Source == '%')
  722.         {
  723.             *Dest++    = '\\';
  724.             *Dest++    = *Source++;
  725.  
  726.             HexMode    = FALSE;
  727.         }
  728.  
  729.         else if(*Source == '(')
  730.         {
  731.             *Dest++        = *Source++;
  732.             BraceMode++;
  733.         }
  734.  
  735.         else if(*Source == ')')
  736.         {
  737.             *Dest++        = *Source++;
  738.             BraceMode--;
  739.             if(PowMode && !BraceMode)
  740.             {
  741.                 *Dest++    = '}';
  742.                 PowMode    = FALSE;
  743.             }
  744.         }
  745.  
  746.         else if(*Source == '^')
  747.         {
  748.             *Dest++        = *Source++;
  749.             *Dest++        = '{';
  750.             PowMode        = TRUE;
  751.         }
  752.  
  753.         else if((*Source == 'e'á|| *Source == 'E') && !HexMode)
  754.         {
  755.             *Dest    = '\0';
  756.             strcat(CopyDest, "\\cdot 10^{");
  757.             Dest    = CopyDest + strlen(CopyDest);
  758.             Source++;
  759.             while(*Source == '-' || (*Source >= '0' && *Source <= '9'))
  760.                 *Dest++    = *Source++;
  761.             *Dest++    = '}';
  762.         }
  763.  
  764.         else if((*Source >= '0' && *Source <= '9') || *Source == '.' || *Source == '/' || *Source == '+' || *Source == '-' || *Source == ' ' || (*Source >= 'a'á&& *Source <= 'f') || (*Source >= 'A' && *Source <= 'F'))
  765.         {
  766.             *Dest++    = *Source++;
  767.             if(*Source == ' ' && PowMode && !BraceMode)
  768.             {
  769.                 *Dest++    = '}';
  770.                 PowMode    = FALSE;
  771.             }
  772.         }
  773.  
  774.         else
  775.             Source++;
  776.     }
  777.  
  778.     *Dest    = '\0';
  779. }
  780.